package com.sefer.dragonfly.client.constants;

import org.apache.commons.lang.StringUtils;

/**
 * 监控运行状态枚举
 * 
 * @see Lifecycle
 * @author xiaofeng 2011-9-15 上午10:02:49
 */
public enum CachePolicyEnum {
	// 默认策略：缓存满时插入数据时剔除最老数据，过期数据直接删除不做处理
	DEFAULT_POLICY("DEFAULT_POLICY"),
	// 缓存满时插入数据时忽略当前数据，过期数据删除不处理
	STORE_DELETE_CURRENT_DESTORY_DELETE("STORE_DELETE_CURRENT_DESTORY_DELETE"),
	// 缓存满时插入数据时剔除最老数据，过期数据记录文件
	STORE_DELETE_LAST_DESTORY_FILE("STORE_DELETE_LAST_DESTORY_FILE"),
	// 缓存满时插入数据时忽略当前数据，过期数据记录文件
	STORE_DELETE_CURRENT_DESTORY_FILE("STORE_DELETE_CURRENT_DESTORY_FILE");

	String type;

	private CachePolicyEnum(String type) {
		this.type = type;
	}

	public static CachePolicyEnum getPolicy(String type) {
		if (StringUtils.isBlank(type)) {
			return DEFAULT_POLICY;
		}
		CachePolicyEnum policy = null;
		try {
			if (policy == null) {
				return DEFAULT_POLICY;
			}
		} catch (IllegalArgumentException e) {
			return DEFAULT_POLICY;
		}
		return policy;
	}
}
